<script setup>
// import MovieList from './MovieList.vue'


import { getHotListAPI } from '@/apis/home.js'
import { ref } from 'vue'
const hotList = ref([])


const getHotList = async () => {
  const res = await getHotListAPI()
  hotList.value = res.items
  console.log(res);
  
}
getHotList()

</script>

<template>
    <div class="container">
        <div class="pannel">
            <h2 class="pannel_head">
                <i class=" rebboIcon iconfont icon-remen"></i>
                热播电影
            </h2>
            <ul class="right_menu">
                <li><a href="#">最近更新 <em>62</em> 部 <span class="line">|</span> </a></li>
                <li><a href="#">更多 ></a></li>
            </ul>
        </div>


        <ul class="movie_list">
            <li  v-for="item in hotList" :key="item.id">
                <RouterLink active-class="active" :to="`/detail/${item.id}`">
                    <div class="movie_head" :style="{backgroundImage: 'url('+item.pic+')'}" >
                        <span class="movie_test_left">{{ item.num == 0 ? "完结" :"更新至"+item.num+"集"  }}</span><span class="movie_test_right">{{item.star}}</span>
                    </div>
                    <div class="movie_info">
                        <p>{{item.title}}</p>
                        <span class="view-text">{{item.des}}</span>
                    </div>
                </RouterLink>
            </li>
       
        </ul>


    </div>
</template>


<style scoped lang='scss'>
.container {
    background: #fff;


    // 设置文本超出使用省略号
    .view-text {
        display: inline-block;
        white-space: nowrap;
        width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .pannel {
        display: flex;
        justify-content: space-between;


        .rebboIcon {
            font-size:24px;
            color: #ff5f00;
        }

        .right_menu {

            li {
                line-height: 70px;
                float: left;

                em {
                    color: #ff5f00;
                }
            }

            a:hover {
                color: $xtxColor;
            }

            .line {
                margin-left: 10px;
                margin-right: 10px;
            }

        }
    }

    .movie_list {
        display: flex;
        height: 500px;
        justify-content: space-between;
        flex-flow: row wrap;



        li {
            width: 19%;
            height: 50%;

            .movie_head {
                width: 100%;
                height: 70%;
                background-size: cover;
                background-position: center;
                background-image: url("@/assets/images/login-bg.png");
                position: relative;
                font-size: 15px;
                font-weight: bold;

                .movie_test_left {
                    color: #fff;
                    position: absolute;
                    bottom: 8px;
                    padding-left: 5px
                }

                .movie_test_right {
                    color: #ff5f00;
                    position: absolute;
                    bottom: 8px;
                    right: 8px;
                }
            }

            .movie_info {
                margin-top: 5px;

                p {
                    font-size: 18px;
                    font-weight: bold;
                }

                span {
                    font-size: 14px;
                    color: #666;
                }

            }
        }
    }
}
</style>